The present invention relates generally to graphical user interfaces, and more particularly to the creation and display of dialogs for different operating systems and different languages.
Dialogs are conventional features of computer programs that have a graphical user interface. In general, a dialog is a window containing explanatory text and/or controls for a user to manipulate. For example, a typical dialog that is displayed when the user attempts to delete a file asks xe2x80x9cAre you sure?xe2x80x9d and provides buttons for the user to press xe2x80x9cDeletexe2x80x9d or xe2x80x9cCancelxe2x80x9d.
Many computer programs are designed with versions for different operating systems (e.g., Windows, UNIX, and Macintosh) and different languages (e.g., English, German, French, and Japanese). The text displayed in dialogs in the program""s graphical user interface should correspond to the program""s language version. For example, the xe2x80x9cCancelxe2x80x9d button should contain the text xe2x80x9cAbbrechenxe2x80x9d in the German version and xe2x80x9cAnnulerxe2x80x9d in the French version. The different text strings used in the dialog for the different languages usually have different sizes. In addition, different operating systems usually have different fonts and controls with different shapes. In short, the size and shape of the elements in a dialog depend upon the operating system and the language. Therefore, a dialog should be laid out for each combination of operating system and language in order to ensure an aesthetically pleasing visual appearance. Conventionally, this layout is performed manually by the developer by dragging each element into a desired position, or by specifying the position and size of each element numerically. Unfortunately, the manual layout process is time-consuming and thus costly.
In one aspect, the invention is directed to a method of creating a dialog. A dialog definition having a description of the relative positions of a plurality of dialog elements is received in a computer. User input identifying an operating system in which the dialog will be displayed from a plurality of available operating system is received. The size of the elements in the identified operating system is identified in the computer, and the description is interpreted in the computer to lay out the dialog.
Implementations of the invention may include the following. The size of the elements for the identified operating system may be retrieved from a configuration file containing element size information for a plurality of operating systems. The description may include a hierarchical array of dialog elements with at least one container containing at least one dialog element. The description may include a layout direction, a horizontal layout alignment, e.g., left, center, right, flush and expanded justifications, a vertical layout alignment, e.g., top, middle, bottom, baseline, flush and expanded justifications, for each container. The description may also include a layout spacing for each element in the container. One or more default values may be determined. The dialog elements may be located in a dialog window, and laying out the dialog may include determining the positions of the elements in the coordinate system of the dialog window.
In another aspect, the invention is directed to a method of creating a dialog in which a dialog definition having a description of the relative positions of a plurality of dialog elements and a key associated with at least one element is received in a computer. User input identifying a language in which the dialog will be displayed from a plurality of available languages is received, and a language file is received in the computer. The language file contains a text string for the identified language associated with the key. The size of the elements in the identified language is identified with the computer using the text string in the element associated with the key, and the description is interpreted in the computer to lay out the dialog.
Implementations of the invention may include the following. The language file may be selected from a plurality of language files, there being one language file for each available language. Alternately, the text string may be selected from a plurality of text strings in the language file, the language file including one text string for each available language. The dialog definition may include a default text string. The size of the elements may be determined by retrieving font metrics for an operating system and calculating the size of the text string from the font metrics. The text string, which may represent a control property, e.g., a minimum size, of the associated element, may be substituted for the key.
In another aspect, the invention is directed to a method of creating a dialog. A dialog definition is received in a computer, and the description is interpreted in the computer to lay out the dialog. The definition has a hierarchical array of elements including a first container containing a first element and a second element. The hierachical array further includes a third element that is not contained by the first container. The definition has a first portion describing the relative positioning of first and second elements within the first container and a second portion describing the relative positioning of the first and third elements.
Implementations of the invention may include the following. The relative positioning of the first and third elements may be selected from a horizonal alignment, e.g., right edge, center, left edge, and width, and a vertical alignment, e.g., top edge, middle, bottom edge, baseline, and height. The second element may contain the third element, or the first element may contain the third element, or the third element may be the first container, or the hierarchical array may include a second container that contains the first container and the third element.
In another aspect, the invention is directed to a method of creating a dialog. A dialog definition is received in a computer. The definition has a hierarchical array of elements and a first portion describing the relative positioning of elements that are in the same container and a second portion having at least one constraint describing the relative positioning of elements that are not in the same container. The dialog is laid out in the computer according to the first portion of the description to determine default positions for the dialog elements, and the constraints in the second portion of the dialog are applied.
Implementations of the invention may include the following. A minimum size may be determined for each element. The first portion of the description may include at least one alignment term to describe the relative positioning of elements, and the default positions of the elements may be based on the alignment term. The alignment terms may be disregarded when the constraints are applied. The constraint may describe the relative positioning of a first element and a second element. A range of possible positions, e.g., the difference between left and right justifications of that element, may be determined for the first and second elements, a target position in the range of possible positions may be selected, and the first and second elements may be located at the target position. A minimum difference between a target position that satisfies the constraint and the default position may be determined. The elements may not be reduced below their minimum sizes. The other elements in the dialog may be relaid.
In another aspect, the invention is directed to a method of creating a dialog definition, in which a hierarchical array of dialog elements is generated in a computer. The hierarchical array has at least one container containing at least one dialog element. User input is received specifying a layout property for the container describing the relative positions of the dialog elements inside the container, and the hierarchical array and layout properties are stored in a dialog definition.
Implementations of the invention may include the following. A key may be assigned to at least one dialog element, and user input designating a text string may be received. A language file containing the text string and the key may be generated, and the language file may be stored with the dialog definition. The hierarchical array may include a second element that is not in the same container as the first element, and a constraint specifying an alignment between the first and second elements may be added to the description. User input assigning a minimum size to the first element may be received. The layout property may be a layout direction, a layout spacing, a horizontal alignment or a vertical alignment.
The advantages of the invention may include the following. Given a dialog definition, an aesthetically pleasing dialog may be automatically generated for each combination of operating system and language. This significantly reduces the time and cost of generating different versions of a program for different operating systems and languages, and reduces the errors that may occur during manual layout of a dialog. In addition, the invention may be embedded in application programs to generate dialogs in a selected language at run-time. This permits a single program to be used for multiple languages.